package com.hjj.concurrence.syncMethod.t6;

public class PublicCar {
    public String username = "A";
    public String password = "AA";

    public synchronized void setValue(String username, String password) {
        try {
            this.username = username;
            Thread.sleep(5000);
            this.password = password;
            System.out.println("setValue method thread name=" + Thread.currentThread().getName() + " username=" + username + " password=" + password);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }

    public synchronized void getValue() {
        System.out.println("getValue method thread name=" + " username=" + username + " password=" + password);
    }

    public static void main(String[] args) {
        try {
            PublicCar publicCar = new PublicCar();
            new ThreadA(publicCar).start();
            Thread.sleep(200);
            publicCar.getValue();
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}
